package com.hualan.controller;

import com.hualan.domain.Course;
import com.hualan.domain.CourseCui;
import com.hualan.service.CourseServicecui;
import com.hualan.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/course")
public class CourseControllerCui {
    @Autowired
    private CourseServicecui courseService;

    @GetMapping ("/findCourseById")
    //根据id查看课程信息
   public R findCourseById(Long id){
        return R.success(courseService.findCourseById(id));

    }
/*//查看所有课程小程序用
@GetMapping("/findAllCourse22")
public  R findAllCourse22(){
    return R.success(courseService.findAllCourse22());
}*/


    @GetMapping("/findAllCourse")
    //查看所有课程信息
    public  R findAllCourse(){
        return R.success(courseService.findAllCourse());
    }
  /*  public R findAllCourse(@RequestParam(name = "pageNum", defaultValue = "1") int pageNum, @RequestParam(name = "pageSize", defaultValue = "3") int pageSize) {
        PageInfo<Course> list = courseService.findAllCourse(pageNum, pageSize);
        return R.success(list);
    }*/

    //动态增加
    @PostMapping("/addSelective")
    public R addSelective(Course record){
        return R.success(courseService.addSelective(record));
    }

    //通过id删除
    @DeleteMapping("/removeById")
    public R removeById(Long id){
        return R.success(courseService.removeById(id));
    }

    //动态修改
    @PostMapping("/changeSelective")
    public  R changeSelective(CourseCui courseCui){
        return R.success(courseService.changeSelective(courseCui));
    }

    //通过课程名模糊查询
    @GetMapping("/findByLikeCourseName")
    public R findByLikeCourseName(String coursename){
        return R.success(courseService.findByLikeCourseName(coursename));
    }


}
